package com.hcxdi.base.presenter;

import android.support.annotation.Nullable;

/**
 * Created by jiajiabao on 16-11-14.
 */
public interface Presenter<V> {

        /**
         * Called when the view attached to the screen.
         * <p>
         * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()}
         * and {@link android.view.View#onAttachedToWindow()}.
         * @param view the view that the presenter interacts with
         */
        void onViewAttached(V view);

        /**
         * Called when the view detached from the screen.
         * <p>
         * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()}
         * and {@link android.view.View#onDetachedFromWindow()}.
         */
        void onViewDetached();

        /**
         * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed.
         * <p>
         * Note that on configuration changes like rotation, presenter instance will be alive.
         */
        void onDestroyed();

        /**
         * @return Returns true if the view is currently attached to the presenter, otherwise returns false.
         **/
        boolean isViewAttached();

        /**
         * @return Returns the attached view. If view is already detached, null will be returned.
         */
        @Nullable
        V getView();
}
